package com.ylr.send.common.enums;

import com.ylr.base.common.dto.NameValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Created by IntelliJ IDEA.
 *
 * @author wyw
 * date: 2023-06-14 15:55:45
 * className: SmsChannelEnum 短信渠道枚举类
 * version: 1.0
 * description:
 */
@Getter
@ToString
@AllArgsConstructor
public enum SmsChannelEnum {

    ALI(1, "阿里云"),
    ;

    /**
     * 值
     */
    private final Integer value;

    /**
     * 名称
     */
    private final String name;

    /**
     * 获取短信渠道枚举对象
     * @param value 参数值
     * @return 短信渠道枚举对象
     */
    public static SmsChannelEnum getChannelEnum(Integer value) {
        for (SmsChannelEnum channelEnum : values()) {
            if (channelEnum.value.equals(value)) {
                return channelEnum;
            }
        }
        return null;
    }

    /**
     * 获取短信渠道枚举列表
     * @return 短信渠道枚举列表
     */
    public static List<NameValue<Integer>> getChannelEnumList() {
        return Stream.of(values())
                .map(smsChannelEnum -> new NameValue<>(smsChannelEnum.name, smsChannelEnum.value))
                .collect(Collectors.toList());
    }
}
